import wepy from 'wepy';
import api from '@/api/api';

export default class GetDetail extends wepy.mixin {
  data = {
    detail: {},
    imgList: [],
    e: {}
  }

  async getDetail() {
    // console.log(e);
    let e = this.e;
    let rlt = await api.detail({
      query: { passiveUid: e.ouid, type: e.type, cardId: e.id }
    });
    if (+rlt.data.code === 12000) {
      this.detail = rlt.data.data;

      let imgList = [];
      let cardImg = rlt.data.data.cardImg;
      let backImg = rlt.data.data.backImg;
      cardImg && imgList.push(cardImg);
      backImg && imgList.push(backImg);
      this.imgList = imgList;

      this.$apply();
    }
  }

  onLoad(e) {
    this.e = e;
    this.getDetail();
  }
}